<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
</body>
<script>
    // test()   =>检索字符串,字符串验证
    // exec()   =>检索字符串,字符串匹配

    // 贪婪匹配 

    var str = "?user=a123123&pwd=456456"

    // var reg = /(\w+)=\w+/;
    var reg = /(\w+)=([^&]+)/g;
    console.log(reg.exec(str));

    var reg = /(\w+)=([^&]+)/g;
    console.log(reg.exec(str));

    /*  
    while (true) {
        var reg = /(\w+)=([^&]+)/g;
        var arr = reg.exec(str);
        if (arr) {

        } else {
            break;
        }
    } 
    */

    // var arr = null;
    // while (arr = reg.exec(str)) {
        
    // }


</script>

</html>